package com.mobileagri.backoffice.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.mobileagri.backoffice.service.UtilisateurService;

/**
 * Controller - Spring
 * 
 * 
 * @author LOUVET Romain
 */
@Controller
public class StatController {

	private UtilisateurService utilisateurService;

	@RequestMapping(value = "stat/getAvancement", method = RequestMethod.GET)
	public @ResponseBody
	Double view2(@RequestParam String userName) throws Exception {

		try {
			Double avancement = utilisateurService.getAvancement(userName) * 100;

			int i = (int) (avancement * 100);
			avancement = (double) (i / 100.0);

			return avancement;

		} catch (Exception e) {
			throw new Exception(e);

		}

	}

	@Autowired
	public void setContactService(UtilisateurService utilisateurService) {
		this.utilisateurService = utilisateurService;
	}

}
